<#import "/layout/mainLayout.html" as mainLayout />

<#macro mainheading>

</#macro>
<#assign mainheading = mainheading in mainLayout />

<#macro maincontent>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="col-xs-8">
                        <div class="box-primary">
                            <!-- form start -->
                            <form id="adminuserform" class="form-horizontal" method="post"
                                  enctype="multipart/form-data">
                                <div class="" box-body id="box-body">

                                        <div class="form-group">
                                            <label for="user_name"
                                                   class="col-sm-2 control-label">用户名称
                                            </label>
                                            <div class="col-sm-3">
                                                <input type="text" class="form-control"
                                                       name="user_name"
                                                       id="user_name"
                                                       placeholder="用户名称">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label for="user_phone"
                                                   class="col-sm-2 control-label">电话
                                            </label>
                                            <div class="col-xs-3">
                                                <input type="text" class="form-control"
                                                       name="user_phone"
                                                       placeholder="电话"
                                                       id="user_phone" >
                                            </div>
                                        </div>

                                        <div class="form-group">
                                        <label for="user_role"
                                               class="col-sm-2 control-label">角色
                                        </label>
                                        <div class="col-xs-3">
                                           <select class="form-control"  id="user_role" name="user_role">

                                           </select>
                                        </div>
                                        </div>
                                    <div class="form-group">
                                        <label for="user_pwd"
                                               class="col-sm-2 control-label">密码
                                        </label>
                                        <div class="col-xs-3">
                                            <input type="password" class="form-control"
                                                   name="user_pwd"
                                                   placeholder="密码"
                                                   id="user_pwd" >
                                        </div>
                                    </div>
                                </div><!-- /.box-body -->
                                <div class="box-footer">
                                    <button type="button" class="btn btn-info pull-right"
                                            onclick="adminUserAdd()">添加
                                    </button>
                                </div><!-- /.box-footer -->
                            </form>
                        </div>
                    </div>
                </div><!-- /.box -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </section>

</#macro>
<#assign maincontent = maincontent in mainLayout />

<#macro mainfooter>
    <script src="/js/jquery/jquery.form.js"></script>

    <script type="text/javascript">
        FillRoleSelect('user_role','');

        function adminUserAdd() {
            if (!$('#user_name').val()) {
                dialog({
                    title: '提示',
                    content: '请输入价格标签名称！',
                    cancel: false,
                    ok: function () {
                    }
                }).width(320).showModal();
                return;
            }
            var options = {
                url: '/api/adminuser/useradd',
                type:'post',
                success: function (data) {
                    if (data) {
                        if (data.code=='OperateOk') {
                            dialog({
                                title: '提示',
                                content: '操作成功！',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                        }
                        else {
                            dialog({
                                title: '提示',
                                content: '<p style="">操作失败！</br>'+data.errorMsg+'!</p>',
                                cancel: false,
                                ok: function () {
                                }
                            }).width(320).showModal();
                        }
                    }
                }
            };
            $("#adminuserform").ajaxSubmit(options);
        }
    </script>
</#macro>
<#assign mainfooter = mainfooter in mainLayout />
<@mainLayout.page title="用户管理"/>